/**
 * 2017年11月22日
 */
package com.alibaba.study.io;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

/**
 * @author Alex
 *
 */
public class Charset {
	public static void main(String[] args) throws UnsupportedEncodingException {
		char arr[] = new char[]{'张','志','东','G','E','T'};
		for(int i= 0;i<arr.length;i++){
			System.out.println(Arrays.toString(char2byte(arr[i])));
			
			
		}
		
		String s = "张志东GET";
		byte[] sArr = s.getBytes("gbk");
		for(int i = 0 ;i<sArr.length;i++){
			System.out.println(Integer.toHexString(sArr[i]));
		}
		byte b =  (byte)0xe5;
		byte b1 =  (byte)0xbc;
		byte b2 =  (byte)0xa0;
		String res = new String (new byte[]{b,b1,b2});
		System.out.println(res);
		
	}
	public static byte[] char2byte(char c){
		byte[] b = new byte[2];
		b[0] = (byte) ((c & 0xFF00) >> 8);
        b[1] = (byte) (c & 0xFF);
        return b;
	}
}
